package com.shuyan.base.algorithm;

import com.shuyan.base.algorithm.po.User;

import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class
Exercise08 {
    public static void main(String[] args) {
        // 将Stream转换成容器或Map
        Stream<String> stream = Stream.of("I", "love", "you", "too");
        Map<String, Integer> map = stream.collect(Collectors.toMap(Function.identity(), String::length));
        System.out.println(map);
        List<User> list=Stream.of(new User("zhangsan",20),new User("lisi",21)).collect(Collectors.toList());
        //list.stream().peek(e->{e.setAge(99);});
        list.stream().map(e->{e.setAge(99);return e;});
        System.out.println(list);
    }
}
